package com.thinkTank.oa.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.thinkTank.oa.base.BaseServiceImpl;
import com.thinkTank.oa.dao.CustomerMapper;
import com.thinkTank.oa.dao.PersonMapper;
import com.thinkTank.oa.entity.Customer;
import com.thinkTank.oa.entity.Person;
import com.thinkTank.oa.service.CustomerService;
import com.thinkTank.oa.service.PersonService;

@Transactional
@Service("CustomerService")
public class CustomerServiceImpl extends BaseServiceImpl<Customer> implements CustomerService {

	@Autowired
	private CustomerMapper customerMapper;
	
	@Autowired
	private PersonMapper personMapper;

	public CustomerMapper getConferenceMapper() {
		return (CustomerMapper) super.getBaseMapper();
	}

	@Autowired
	public void setConferenceMapper(CustomerMapper conferenceMapper) {
		super.setBaseMapper(conferenceMapper);
	}

	
	@Override
	public void addCustomerContact(Customer customer, Person person) {
		customerMapper.update(customer);
		personMapper.addPerson(person);
		
	}

	/**
	 * 通过客户id，查出对应的客户信息
	 */
	@Override
	public Customer getByCustomerNumber(int customerNumber) {
		return customerMapper.getByCustomerNumber(customerNumber);
	}

	@Override
	public List<Customer> queryAllCustomer(Customer customer) {
		// TODO Auto-generated method stub
		return customerMapper.queryAllCustomer(customer);
	}

	@Override
	public List<Customer> queryNotInCustomer(Customer customer) {
		// TODO Auto-generated method stub
		return customerMapper.queryNotInCustomer(customer);
	}

	@Override
	public List<Map<Object, Object>> findCustomerByIndex(Integer count) {
		// TODO Auto-generated method stub
		 return customerMapper.findCustomerByIndex(count);
	}
	
}
